package com.alex.statistics.method.explorationAnalysis;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * 数据点对象 - 表示多维空间中的一个点
 */
@Data
@Schema(description = "多维数据点")
public class DBSCANDataPoint {
    @Schema(description = "数据点索引", example = "0")
    private final int index;

    @Schema(description = "特征向量", example = "[1.2, 3.4]")
    private final double[] features;

    @Schema(description = "所属簇ID(-1表示噪声点)", example = "1")
    private int clusterId = -1;

    @Schema(description = "是否噪声点", example = "false")
    private boolean isNoise = false;

    public double distanceTo(DBSCANDataPoint other) {
        double sum = 0;
        for (int i = 0; i < features.length; i++) {
            sum += Math.pow(features[i] - other.features[i], 2);
        }
        return Math.sqrt(sum);
    }
}